package com.yidu.StockControl.mapper;


import com.yidu.StockControl.entity.CashInventory;
import com.yidu.StockControl.entity.SecurityInventors;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * 证券库存     证券库存        证券库存        证券库存
 */
@Repository
public interface SecurityInventorsMapper {
    /**
     * 查询
     * @return
     */

    @Select("select * from securityinventors WHERE 1=1 ${strWhere} LIMIT #{page},#{limit}")
    public List<SecurityInventors> selectSecurityInventors(Map map);

    @Select("select count(*) from securityinventors")
    int selectSecurityInventorsCount();

    @Insert("insert into securityinventors values(#{securityInventorsId},#{securityInventorsTime},#{fundId}," +
                                                    "#{securityId},#{securityPrice},#{securityNum},#{securityMoney})")
    public int insertSecurityInventors(SecurityInventors securityInventors);

    @Update("update securityinventors set securityInventorsTime=#{securityInventorsTime},fundId =#{fundId},securityId=#{securityId},securityPrice=#{securityPrice},securityNum=#{securityNum},securityMoney=#{securityMoney}" +
            "where securityInventorsId= #{securityInventorsId}")
    public void updateSecurityInventors(SecurityInventors securityInventors);

    @Delete("delete FROM securityinventors where securityInventorsId = #{securityInventorsId}")
    public  void  deleteSecurityInventors(String securityInventorsId);

    @Delete("delete FROM securityinventors where securityInventorsId = #{securityInventorsId} and fundId = #{fundId} and securityInventorsTime = DATE_FORMAT(DATE_ADD(STR_TO_DATE(#{dateTime},'%Y-%m-%d'),INTERVAL -1 DAY),'%Y-%m-%d')")
    public  int  deleteSecurityInventorsDate(String securityInventorsId, String fundId, String dateTime);

}
